import {defineStore} from "pinia";
import {ref} from 'vue';

export const useTokenStore = defineStore('token', ()=>{
    //token
    const token = ref('')
    const setToken = (newToken)=>{
        token.value = newToken
    }
    const removeToken = ()=>{
        token.value=''
    }
    //全局变量
    //category
    const category = ref('全部图书')
    const setCategory = (newCategory) => {
        category.value = newCategory
    }
    const removeCategory = () => {
      category.value = '全部图书'
    }
    //bookId
    const bookId = ref('')
    const setBookId = (newBookId) => {
        bookId.value = newBookId
    }
    const removeBookId = () => {
      bookId.value = ''
    }
    //bookName
    const bookName = ref('')
    const setBookName = (newBookName) => {
        category.value = '全部图书'
        bookName.value = newBookName
    }
    const removeBookName = () => {
        bookName.value = ''
    }

    return{
        token, setToken, removeToken,
        category, setCategory, removeCategory,
        bookId, setBookId, removeBookId,
        bookName,setBookName,removeBookName
    }
},{
    persist: true
})